import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-31
 * Time: 23:40
 */
public class demo5 {
    public static void main(String[] args) {
        AtomicInteger s = new AtomicInteger(1);
        ExecutorService pool = Executors.newFixedThreadPool(10);
        for(int i=0;i<1000;i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    s.getAndIncrement();
                }
            });
        }
        pool.shutdown();
        try {
// 等待所有线程执行完毕
            pool.awaitTermination(Long.MAX_VALUE,TimeUnit.SECONDS);
        } catch (InterruptedException e) {
        }
        System.out.println(s);

    }
}
